package libase.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author aspr0
 */
@Entity
@Table (name = "PREFERENCE")
@XmlRootElement
@NamedQueries (
        {
    @NamedQuery (name = "Preference.findAll", query = "SELECT p FROM Preference p"),
    @NamedQuery (name = "Preference.findByName", query = "SELECT p FROM Preference p WHERE p.name = :name"),
    @NamedQuery (name = "Preference.findByValue", query = "SELECT p FROM Preference p WHERE p.value = :value")
})
public class Preference implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic (optional = false)
    @NotNull
    @Size (min = 1, max = 200)
    @Column (name = "NAME")
    private String name;
    @Size (max = 200)
    @Column (name = "VALUE")
    private String value;

    public Preference()
    {
    }

    public Preference(String name)
    {
        this.name = name;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (name != null ? name.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Preference))
        {
            return false;
        }
        Preference other = (Preference) object;
        if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "libase.entity.Preference[ name=" + name + " ]";
    }
}
